package Utils;

import com.alibaba.fastjson.JSON;
import entity.user;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class JSONUtil {
    public static String toJSONString(Object object){
        return JSON.toJSONString(object);
    }

    public static void main(String[] args) {
//        Map<String, Object> stringObjectMap = new HashMap<>();
//        stringObjectMap.put("k1","这是字符串");
//        stringObjectMap.put("k2",new int[]{1,2,3,4,5});
//        stringObjectMap.put("k3", Arrays.asList(1,2,3,4,5));
//        stringObjectMap.put("k4",new user());
        System.out.println(toJSONString("{'errno': 0," +
                "    \"data\": {\n" +
                "        \"url\": \"xxx\", // 图片 src ，必须\n" +
                "        \"alt\": \"yyy\", // 图片描述文字，非必须\n" +
                "        \"href\": \"zzz\" // 图片的链接，非必须\n" +
                "    }\n" +
                "}"));

    }
}
